#ifndef __HAL_ESP8266_H__
#define __HAL_ESP8266_H__

#include <rtthread.h>
#include "gd32vf103.h"


/******************************* ESP8266 外部全局变量声明 ***************************/
#define RX_BUF_MAX_LEN     1024                                     //最大接收缓存字节数

struct  STRUCT_USART_Fram_S                                  //串口数据帧的处理结构体
{
	char  Data_RX_BUF [ RX_BUF_MAX_LEN ];

    uint16_t FramLength;
    struct {
		  uint8_t FramStartFlag;
		  uint8_t FramFinishFlag;
	} InfBit;
} ;

extern struct  STRUCT_USART_Fram_S Esp8266_Frame_Record;


/******************************** ESP8266 连接引脚定义 ***********************************/
#define      ESP8266_CH_PD_APBxClock_FUN                   RCC_APB2PeriphClockCmd
#define      ESP8266_CH_PD_CLK                             RCU_GPIOB
#define      ESP8266_CH_PD_PORT                            GPIOB
#define      ESP8266_CH_PD_PIN                             GPIO_PIN_1

#define      ESP8266_RST_APBxClock_FUN                     RCC_APB2PeriphClockCmd
#define      ESP8266_RST_CLK                               RCU_GPIOB
#define      ESP8266_RST_PORT                              GPIOB
#define      ESP8266_RST_PIN                               GPIO_PIN_0


/*********************************************** ESP8266 函数宏定义 *******************************************/

#define     hal_esp8266_ch_enable()                 gpio_bit_set ( ESP8266_CH_PD_PORT, ESP8266_CH_PD_PIN )
#define     hal_esp8266_ch_disable()                gpio_bit_reset ( ESP8266_CH_PD_PORT, ESP8266_CH_PD_PIN )

#define     hal_esp8266_rst_high()            gpio_bit_set ( ESP8266_RST_PORT, ESP8266_RST_PIN )
#define     hal_esp8266_rst_low()             gpio_bit_reset ( ESP8266_RST_PORT, ESP8266_RST_PIN )


void hal_esp8266_gpio_init ( void );

void hal_esp8266_uart_init ( void );

void hal_esp8266_printf ( char * Data, ... );

void hal_esp8266_delayms ( int ms );


#endif

